package homework;

public class day03 {
    public static void main(String[] args) {
        System.out.println(10%5);//0
        System.out.println(5%2);//1
        System.out.println(2%5);//2

        //自增,单独使用时
        int a=5,b=5;
        a++;
        ++b;
        System.out.println(a);//6
        System.out.println(b);//6

        //被使用时
        int a1=5,b1=5;
        int c = a1++;
        int d =++b1;
        System.out.println(a1);//6
        System.out.println(b1);//6
        System.out.println(c);//5
        System.out.println(d);//6

        //自减,单独使用时
        int a2=5,b2=5;
        a2--;
        --b2;
        System.out.println(a2);//4
        System.out.println(b2);//4

        //被使用时
        int a3=5,b3=5;
        int c1 = a3--;
        int d1 = --b3;
        System.out.println(a3);//4
        System.out.println(b3);//4
        System.out.println(c1);//5
        System.out.println(d1);//4
        //关系
        int a4=5,b4=10,c2=5;
        boolean b5 = b4>a4;
        System.out.println(b5);//true
        System.out.println(a4<b4);//true
        System.out.println(a4>=c2);//true
        System.out.println(b4<=c2);//false
        System.out.println(a4==c2);//true
        System.out.println(a4!=b4);//true

        System.out.println(a4+b4>c2);//true
        System.out.println(a4+c2<=b4);//true
        System.out.println(b4%c2==a4);//false
        System.out.println(a4++>5);//false
        System.out.println(a4++>5);//true
        //逻辑与
        int q=5,w=10,e=5;
        System.out.println(q+e>=w && e>w);//false
        System.out.println(q>=w && w>e);//false
        System.out.println(q==e && w>e);//true
        System.out.println(q!=e && q++<e);//false

        boolean w3 = q>w && e++>2;
        System.out.println(w3);//false
        System.out.println(e);//5
        //逻辑或
        System.out.println(q+e>=w || e>w);//true
        System.out.println(q>=w || w>e);//true
        System.out.println(q==e || w>e);//true
        System.out.println(q!=e || q++<e);//false

        boolean w4 = q<w || e++>2;
        System.out.println(w4);//true
        System.out.println(e);//5

        //逻辑非
        boolean w2 = !(q<w);
        System.out.println(w2);//false
        System.out.println(!(q>w));//true
        //赋值
        int f = 5;
        f += 10;
        System.out.println(f);//15
        f *= 2;
        System.out.println(f);//30
        f /= 6;
        System.out.println(f);//5
        f %= 8;
        System.out.println(f);//5

        short s = 5;
        s = (short)(s+10);
        s += 10;

        //字符串连接
        int age = 29;
        System.out.println("age=");//age=
        System.out.println(age);//29
        System.out.println("age="+age);//age=29
        System.out.println("我今年"+age+"岁了");
        String name = "YHY";
        System.out.println("name=");//name=
        System.out.println(name);//YHY
        System.out.println("name="+name);
        System.out.println("我叫"+name+",今年"+age+"岁了");

        System.out.println(10+20+""+30);//3030
        System.out.println(10+20+30+"");//60
        System.out.println(""+10+20+30);//102030

        //条件
        int num =5;
        int flag = num>0?1:-1;
        System.out.println(flag);//1

        int n=6,m=5;
        int max = n>m?n:m;
        System.out.println(max);//6

        //分支
        //满500打8折
        double price = 500.0;
        if (price>=500){
            price *= 0.8;
        }
        System.out.println(price);//400.0

        //判断成绩是否合法
        int score = 95;
        if (score>=0 && score <=100){
            System.out.println("成绩合法");
        }
        System.out.println("继续执行...");

        //满500打8折，不满500打9折
        double p1 = 600.0;//600.0,300.0
        if (p1>=500){
            p1 *= 0.8;
        }else {
            p1 *= 0.9;
        }
        System.out.println(p1);//480.0,270.0
        //判断成绩合法还是不合法
        int s1 = 95;//95,-1,150
        if (s1>=0 && s1<=100){
            System.out.println("成绩是合法的");
        }else {
            System.out.println("成绩不合法");
        }

        //满2000打5折，满1000不满2000打7折，满500不满1000打8折，不满500打9折
        double p2 = 5000.0;//5000.0,1000.0,600.0,300.0
        if (p2>=2000){
            p2 *= 0.5;
        }else if (p2>=1000){
            p2 *= 0.7;
        }else if (p2>=500){
            p2 *= 0.8;
        }else {
            p2 *= 0.9;
        }
        System.out.println(p2);//2500.0,700.0,480.0,270.0
    }
}
